import time
print('==========================开始下载==========================')
def progress_bar(iteration, total, length=50):
    """
    显示一个动态的文本进度条。
    
    :param iteration: 当前的迭代次数
    :param total: 总的迭代次数
    :param length: 进度条的长度
    """
    percent = ("{0:.1f}").format(100 * (iteration / float(total)))
    filled_length = int(length * iteration // total)
    bar = '*' * filled_length + '.' * (length - filled_length)

    print('\r [%s] %s%%' % (bar, percent), end = '\r')
    # 打印换行符，当迭代完成时
    if iteration == total: 
        print()
        print('==========================下载完成==========================')

# 示例使用
total_iterations = 50
for i in range(1, total_iterations + 1):
    progress_bar(i, total_iterations)
    time.sleep(0.1)  # 模拟任务执行时间